#!/usr/bin/python
# -*- coding: utf-8 -*-

#This file is part of pyLot library.
#
# pyLot is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyLot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pyLot.  If not, see <http://www.gnu.org/licenses/>.

__author__ = u'Pierre Puiseux, Guillaume Baty'
__copyright__ = u"Copyright 2011-2012 (C) andheo, Université de Pau et des Pays de l'Adour"
__credits__ = [u'Pierre Puiseux', u'Guillaume Baty']
__license__ = "GNU Lesser General Public License"

__all__ = [u"UiInterface"]

from _pylot.minimal.utils import check_type

from _pylot.interfaces.handler import (HandlerInterface, DEFAULT_HANDLER)
from _pylot.interfaces.iohandler import IOHandlerInterface
from _pylot.interfaces.processhandler import ProcessHandlerInterface

class UiInterface (object):

  def __init__(self, handler=None):
    self._children = {}
    if handler is None :
      handler = DEFAULT_HANDLER
    self._handler = handler

  def init(self, io_handler=None, process_handler=None):
    self.handler.init(io_handler, process_handler)

  def _gethandler(self):
    u"""The handler to which are delegated all works.
    :returns: the handler.
    :rtype: :class:`~_pylot.interfaces.HandlerInterface`
    """
    return self._handler

  def _sethandler(self, handler=None):
    u"""The handler to which are delegated all works.
    :type handler: :class:`~_pylot.interfaces.HandlerInterface`
    """
    check_type(u'handler', handler, HandlerInterface)
    self._handler = handler #the handler to which are delegated all works.

  u"""the handler to which are delegated all works."""

  handler = property(_gethandler, _sethandler)
